svn 代码迁移到git

您所在的位置:网站首页 dumping stack trace to svn 代码迁移到git

svn 代码迁移到git

2024-07-09 09:53| 来源: 网络整理| 查看: 265

svn 代码迁移到git 1、收集svn上的人员信息,并编辑成git能识别的账号2、使用 git svn clone 命令 克隆代码(以下步骤建议在win10上操作)3、用git命令查看提交记录 (按q退出 )4、关联git上的项目地址5、 将本地代码提交到远程仓库6、合并到master分支 接下来记遇到问题即解决方法

因公司架构变动,现要求将手中负责的项目从svn上迁移至git,其实迁移很简单,但是还需要保留 svn上的提交记录,就无行的给工作增添了一些难度,得还好网上教程比较多,这里是我实战的笔记,仅供参考。

1、收集svn上的人员信息,并编辑成git能识别的账号 svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" "}' | sort -u > users.txt

注:此命令最好是在mac或LINUX系统上执行生成 users.txt

执行成功后会在 svn目录生成 users.txt ##2、 将用户信息修改成git能够识别的格式

zhansan = 张三 lisi = 李四 wangwu = 王五

注:如果这个时候还知道用户的邮箱可先保持与前面英文账号保持一致

2、使用 git svn clone 命令 克隆代码(以下步骤建议在win10上操作) git svn clone https://svn_project_url/ --no-metadata --authors-file=../users.txt ../bpms-bb

注:svn_project_url 即你的svn代码地址

3、用git命令查看提交记录 (按q退出 ) D:\克隆到本地代码地址> git log 4、关联git上的项目地址 D:\克隆到本地代码地址>git remote add origin https://gitlab.wuhan.cn/project/xiangzi.git

查看关联地址是否正确 git remote -v

5、 将本地代码提交到远程仓库

git pull origin master

如果提交报错 ,说明远程仓库有操作记录,可以使用强制合并提交 git pull origin master --allow-unrelated-histories

6、合并到master分支

git push origin master 这样就基本完成了 迁移工作。

接下来记遇到问题即解决方法

1、 svn迁移到git时因其他原因中断,再次使用clone 命令报错

Using existing [svn-remote "svn"] svn-remote.svn.fetch already set to track :refs/remotes/git-svn

在项目目录上使用命令:git svn fetch 继续操作,可节省不少时间

2、由于项目较大,或者同时执行多个克隆命令 导致空间不足

libsvn: Out of memory - terminating application. 0 [main] perl 641 cygwin_exception::open_stackdumpfile: Dumping stack trace to perl.exe.stackdump

我的解决方法是将窗口关掉,打开新命令窗口 并执行:git svn fetch

3、 svn代码迁移到git ,电脑突然关机,或误操作将命令窗口关闭

.git/svn/refs/remotes/git-svn/index.lock': File exists. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue. write-tree: command returned error: 128

执行命令 git svn fetch 也会报错,需要找到 index.lock,删除掉再执行即可



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3